package com.yh.concert.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import org.springframework.stereotype.Service;
import org.springframework.beans.factory.annotation.Autowired;
import com.ruoyi.common.utils.StringUtils;
import java.util.List;
import java.util.Map;
import com.yh.concert.mapper.YhSiteMapper;
import com.yh.concert.domain.YhSite;
import com.yh.concert.service.IYhSiteService;

/**
 * 场地信息Service业务层处理
 *
 * @author yh
 * @date 2025-02-26
 */
@Service
public class YhSiteServiceImpl extends ServiceImpl<YhSiteMapper, YhSite> implements IYhSiteService {

    @Autowired
    private YhSiteMapper yhSiteMapper;

    /**
     * 查询场地信息列表
     *
     * @param yhSite 场地信息
     * @return 场地信息
     */
    @Override
    public List<YhSite> selectYhSiteList(YhSite yhSite)
    {
        List<YhSite> yhSiteList = yhSiteMapper.selectList(buildQueryWrapper(yhSite));
        return yhSiteList;
    }


    private LambdaQueryWrapper<YhSite> buildQueryWrapper(YhSite query) {
        Map<String, Object> params = query.getParams();
        LambdaQueryWrapper<YhSite> lqw = Wrappers.lambdaQuery();
        lqw.eq(query.getUserId() != null, YhSite::getUserId, query.getUserId());
        lqw.eq(query.getMerchartId() != null, YhSite::getMerchartId, query.getMerchartId());
        lqw.like(StringUtils.isNotBlank(query.getSiteName()), YhSite::getSiteName, query.getSiteName());
        lqw.eq(StringUtils.isNotBlank(query.getIntro()), YhSite::getIntro, query.getIntro());
        lqw.eq(query.getStatus() != null, YhSite::getStatus, query.getStatus());
        lqw.orderByDesc(YhSite::getCreateTime);
        return lqw;
    }

}
